<template>
    <div class="head">
        手动模式
    </div>
    <div class="startset">
        <el-button type="primary" class="button" @click="configSet">模式启用</el-button>
   </div>
    <div class="setblock">
        <el-switch class="switch"
        v-model="value"
        active-text="开机"
        inactive-text="关机"
        @change = handleSwitchChange>
        </el-switch>
    </div>
    <div class="setblock">
        <el-tag size="medium" class="tags">有功功率</el-tag>
        <el-input
        style="width: 300px;"
        v-model="yggl" placeholder="输入功率值"></el-input><span>kw</span>
        <el-button type="primary">有功设置</el-button>
    </div>
    <div class="setblock">
        <el-tag size="medium" class="tags">无功功率</el-tag>
        <el-input
        style="width: 300px;"
        v-model="wggl" placeholder="输入无功值"></el-input><span>kw</span>
        <el-button type="primary">无功设置</el-button>
    </div>
    <el-divider ></el-divider>
    <div class="line-head">
        <span>环境温度过高:</span>
        <el-input  class="elinput"
        placeholder="请输入内容"
        type="number"
        v-model.number="policCfg.remote_adj.upper_limit_env_temp">
      </el-input>
      <span>℃</span>
    </div>

 
</template>
<script lang="ts" setup >
import { ref,onMounted,toRef} from 'vue'
import    service   from '@/tools/request.ts'
const value = ref(false)
const yggl = ref(0)
const wggl = ref(0)

let  senddata = {
    remote_adj_ctrl_table:[]
} 



const policCfg = toRef({
    remote_adj:{
        run_mode:0,
        policy_mode:0,
        proxy_mode:0,//0-sche，1-modbus 2-iec104 3-mudbus-auto  4-iec104-auto
        demand_mode:0,//0-直接计算，1-pid模式
        anti_reflux_mode: 0, //防逆流   0-直接计算，1-pid模式
        load_track_mode:0,//负荷跟踪，0-直接计算，1-pid计算模式
        max_dis_charge_power:100,//最大放电功率
        max_charge_power:100,//最大放电功率
        station_capacity:200,//变压器容量
        increase_capa_para:{
            load_charge_low:0,//负载充电下限
            load_discharge_low:0,//负载放电下限
            load_discharge_ret_diff:0,//放电回差
            ret_diff_pay:0//放电回差区间放电功率
        },
        pid_para:{
            p:10,
            i:20,
            d:30,
        },
        power_para:{
            charge_discharge_mode:1,
            action_power:0,//有功功率
            ReactivePower:0,//无功功率
        },
        air_para:{
            refrigeration_temp:30,//制冷温度
            cooling_return_diff:3,//制冷回差
            heating_temp:8,//制热温度
            heat_return_diff:3,//制热回差
        },
        upper_limit_env_temp:50,//环境温度过高
        soc_para:{
            soc_max:90,
            soc_min:5,
            dis_conn_grid_soc_min: 20,//离网放电soc设置
        },
        cell_para:{
            vol_lower:2.0,//
            vol_hight:3.5,//
            temp_hight:60
        },
        gener_para:{
            vol_hight:400,
            vol_lower:280,
            freq_hight:52,
            FreqLower:49,
            ch_disch_step:10,
        },
        reactive_para:{
            capacitive_reactive:30,//容性无功上限
            sensory_reactive:30,//感性无功上限，
        },
        power_distribution_mode:0,//0-平均分配，基于soc分配，基于bms能力，soc，bms结合
        trans_para:{
            capacity:1000,//变压器容量
            ratio:1,//变比
            demond:10,//需量初始值
        },
        data:{
            start_date:"",
            end_date:"",
            week_day:"",
        },
        priority:6,
        time_line:[
        ]
    },
    remote_ctrl:{
        station_open_ctrl:0,
        station_grid_conn_ctrl:0,
        anti_reflux_ctrl:0,
        grid_capa_ctrl:0,
        grid_demand_ctrl:0,
        environ_temper_protect:0,
        dod_protect:1,
        soc_grid_disconn_protect:0,
        cell_max_vol_protect:0,
        cell_minx_vol_protect:0,
        pack_max_temper_protect:0,
        primary_freq_module_ctrl:0,
        electricity_quality_ctrl:0,
        bms_up_vol_ctrl:0,
    }
})


function configSet(){
    senddata.remote_adj_ctrl_table = []
    senddata.remote_adj_ctrl_table.push(policCfg.value)
    service({
        url:'/v1/policy/set',
        method: 'post',
        data: senddata
    })
}
const handleSwitchChange=(val)=> {
      console.log('Switch value changed to:', val);
    }
</script>
<style>
   
    .setblock{
        margin-top: 10px
    }
    .setblock .tags{
        width:100px;
        left: 100px;
        margin-left: 30px;
        margin-right: 30px;
    }
    .setblock  span{
        margin-right: 10px;
    }
    .setblock .switch{
        margin-left: 30px
    }
    .head{
        text-align:center ;
        font-size: 40px;
        color:green
    }
    .startset{
        margin-top: 10px;
        margin-bottom: 100px;
        text-align: center;
    }
    .startset .button{
        height: 60px;
        font-size: 50px;
    }
    .line-head{
        margin-top: 40px;
        margin-left: 80px;
    }
    .line-head span{
        margin-right: 20px;  
        font-weight: 600; 
        
    }
    .line-head .elinput{
        width: 100px;
    }

</style>